import { Observable } from 'rxjs';

const genError = false;
const observable:Observable<any> = Observable.create(
  (observer: any) => {
    try {
      observer.next("1");
      if(genError){
        throw Error("test error");
      }
      observer.complete();
    } catch (e) {
      observer.error(e);
    }
  }
);

observable.subscribe(
  (value:any) =>{
    console.log('[1]###next###');
    // console.log(value);
  },
  (error:any) => {
    console.log('[1]###error###');
    // console.log(error);
  },
  () => {
    console.log('[1]###complete###');
  }
);
observable.subscribe(
  {
    next:(value:any) => {
      console.log('[2]###next###');
      // console.log(typeof(value));
      // console.log(value);
    },
    complete:() => {
      console.log('[2]###complete###');
      // console.log(error);
    },
    error:(error:any) => {
      console.log('[2]###error###');
      // console.log(error);
    }
  }
);

observable.subscribe(
  {
    complete:() => {
      console.log('[3]###complete###');
      // console.log(error);
    }
  }
);

observable.subscribe(
  {
    error:(error:any) => {
      console.log('[4]###error###');
      // console.log(error);
    }
  }
);

observable.subscribe(
  {
    next:(value:any) => {
      console.log('[5]###next###');
      // console.log(value);
    }
  }
);